package com.by.wx.servlet;
//package servlet;
//
//import java.io.IOException;
//import java.io.PrintWriter;
//
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
//import org.json.JSONObject;
//
//import util.AuthUtil;
//
//public class CallBackServlet extends HttpServlet{
//
//	@Override
//	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//		System.out.println("hahah");
//        String code=req.getParameter("code");
//        String url="https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + AuthUtil.APPID+
//                "&secret=" +AuthUtil.APPSECRET+
//                "&code=" +code+
//                "&grant_type=authorization_code";
//        JSONObject jsonObject = AuthUtil.doGetJson(url);
//        String openid=jsonObject.getString("openid");
//        String token=jsonObject.getString("access_token");
//        String infoUrl="https://api.weixin.qq.com/sns/userinfo?access_token=" +token+
//                "&openid=" +openid+
//                "&lang=zh_CN";
//        JSONObject userInfo=AuthUtil.doGetJson(infoUrl);
//        System.out.println(userInfo);
//        //resp.sendRedirect("http://h5.gzbaoya.cn/wxapp/index.jsp");
//	}
//}
